<!-- 
    箭头函数
    ()=>{}
    const= ()=>{}
 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1.箭头函数是用来简化函数定义语法的
        const fn = () => {
            console.log(123);
        }
        fn();
        console.log('-----------------------');

        //2.函数体中只有一句代码，且代码的执行结果就是返回值，可以省略大括号
        //普遍的写法
        function sum(sum1, sum2) {
            return sum1 + sum2;
        }
        console.log(sum(3, 4));
        console.log('-----------------------');

        //用箭头函数写
        const fun = (sum1, sum2) => sum1 + sum2;

        console.log(fun(5, 6));

        console.log('------------------------------');

        //3.如果形参只有一个，可以省略小括号
        //普通写法
        function fn2(v) {
            return v
        }
        console.log(fn2(3));
        //箭头函数写法
        const fn1 = v => v;
        console.log(fn1(3));




    </script>
</body>

</html>